package net.sxnic.ugr.resource.action;

import net.sxnic.ugr.resource.Resource;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
 


@SuppressWarnings("serial")
public class Save extends ResourceAction  {

	private static Logger logger = LoggerFactory.getLogger(Save.class);

	public void prepare() throws Exception {
		if (StringUtils.isNotBlank(id))
			resource = resourceManager.get(id);
	}

	public String execute() throws Exception {

		try {
			checkRoles(Resource.SYSTEM_ADMIN);

			if (StringUtils.isBlank(resource.getId()))
				resourceManager.save(resource);
			else
				resourceManager.update(resource);

			// 保存成功信息并转向
			msg = "saveSuccess";

		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;

	}

}

	 
	 
